#pragma once
#include "D3DTransform.h"


D3DTransform::D3DTransform()
{
	m_pWorldMatrixBuffer = NULL;
	xScale = 1.0f;
	yScale = 1.0f;
	zScale = 1.0f;

	x = 0.0f;
	y = 0.0f;
	z = 0.0f;

	xAngle = 0.0f;
	yAngle = 0.0f;
	zAngle = 0.0f;
}

void D3DTransform::Release()
{
	if(m_pWorldMatrixBuffer) m_pWorldMatrixBuffer->Release();
}
void D3DTransform::CalculateMatrix(D3DXMATRIX *pMatrixOut)
{
	D3DXMATRIX matScale;
	D3DXMatrixIdentity(&matScale);
	D3DXMatrixScaling(&matScale, xScale, yScale, zScale);

	D3DXMATRIX matTranslation;
	D3DXMatrixTranslation(&matTranslation, x, y, z);

	D3DXMATRIX matRotation;
	D3DXMatrixRotationYawPitchRoll(&matRotation, xAngle, yAngle, zAngle);

	D3DXMATRIX matResult;
	//D3DXMatrixMultiply(&matResult, &matTranslation, &matScale);
	matResult = matScale * matRotation * matTranslation;
	//matResult = matTranslation * matScale;
	D3DXMatrixTranspose(pMatrixOut, &matResult);
}



